<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">
<section class="content-header">
    <h1>发明专利信息维护</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm" onsubmit="return false;">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group">
                                    <label for="query-proCode">专利名称</label>
                                    <input id="query-proCode" type="text" name="name" class="form-control"
                                           placeholder="请输入专利名称">
                                </div>
                                <div class="form-group">
                                    <label for="query-inventor">发明人</label>
                                    <input id="query-inventor" type="text" name="inventor" class="form-control"
                                           placeholder="请输入发明人">
                                </div>
                                <div class="form-group">
                                    <label for="query-taskType">申请类型</label>
                                    <select id="query-taskType" class="form-control" name="taskType">
                                        <option value="" selected="selected">请选择</option>
                                        <option value="发明">发明</option>
                                        <option value="实用新型">实用新型</option>
                                        <option value="外观设计">外观设计</option>
                                        <option value="软件登记">软件登录</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="query=reward">公司专利奖励</label>
                                    <input id="query=reward" class="form-control" type="text" name="reward"
                                           placeholder="请注入公司专利奖励">
                                </div>
                                <div class="form-group">
                                    <label for="query-patentCode">专利编码</label>
                                    <input id="query-patentCode" class="form-control" type="text" name="patentCode"
                                           placeholder="请输入专利编码">
                                </div>
                                <div class="form-group">
                                    <label for="query-projectRemark">涉及项目</label>
                                    <input id="query-projectRemark" class="form-control" type="text"
                                           name="projectRemark" placeholder="请输入涉及项目">
                                </div>
                                <div class="form-group">
                                    <label for="query-status">状态</label>
                                    <select id="query-status" class="form-control" name="status">
                                        <option value="" selected="selected">请选择</option>
                                        <option value="1">未申报</option>
                                        <option value="2">已申报</option>
                                        <option value="3">等待受理</option>
                                        <option value="4">已受理</option>
                                        <option value="5">授权</option>
                                        <option value="6">退回</option>
                                    </select>
                                </div>
                                <button type="button" class="btn-success" id="btn-search"
                                        onclick="js.table.search(table)">
                                    <span class="bold">搜索</span>
                                </button>
                            </div>
                        </div>
                    </form>
                    <button type="button" class="btn-success pull-right" id="btn-add" onclick="openAddModal()">
                        <span class="bold">新增</span>
                    </button>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table" style="width:99.9%;font-size: 12px;"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<!--新增模态框-->
<div class="modal fade" id="addModal" role="dialog" aria-labelledby="addModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>
                <h4 class="modal-title" id="" align="center">新增发明专利信息</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" role="form" id="addForm">
                    <input type="hidden" id="addForm-id" name="id">
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right">申请类型</label>
                        <div class="col-sm-9">
                            <select class="form-control" name="typeName">
                                <option value="" selected="selected">请选择</option>
                                <option value="发明">发明</option>
                                <option value="实用新型">实用新型</option>
                                <option value="外观设计">外观设计</option>
                                <option value="软件登记">软件登记</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" >发明人 ：</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" name="inventor" id="addForm-inventor">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right">提报时间 ：</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control datepicker" name="applyTime" readonly>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right">受理时间 ：</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control datepicker" name="acceptanceTime" readonly>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right">授权时间 ：</label>
                        <div class="col-sm-9">
                            <input class="form-control datepicker" readonly name="authorizedTime" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right">专利编码 ：</label>
                        <div class="col-sm-9">
                            <input class="form-control" type="text" name="patentCode">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right">公司专利奖励 ：</label>
                        <div class="col-sm-9">
                            <input class="form-control" name="reward" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right">状态 ：</label>
                        <div class="col-sm-9">
                            <select class="form-control" name="status">
                                <option value="" selected="selected">请选择</option>
                                <option value="1">未申报</option>
                                <option value="2">已申报</option>
                                <option value="3">等待受理</option>
                                <option value="4">已受理</option>
                                <option value="5">授权</option>
                                <option value="6">退回</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label>设计所 ：</label>
                        <div class="col-sm-9">
                            <input type="text" name="deptName" class="form-control">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right">专业领域 ：</label>
                        <div class="col-sm-9">
                            <input class="form-control" type="text" name="field">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right">涉及项目</label>
                        <div class="col-sm-9">
                            <textarea name="projectRemark" rows="3"></textarea>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button class="btn btn-default" data-dismiss="modal" type="button">关闭</button>
                <button type="button" class="btn btn-primary" onclick="saveMaintain()">添加</button>
            </div>
        </div>
    </div>
</div>
<!--修改模态框-->
<div class="modal fade" id="editModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button class="close" type="button" data-dismiss="modal" aria-hidden="true">x</button>
                <h4 class="modal-title" align="center">维护发明专利信息</h4>
            </div>
            <div class="modal-body">

            </div>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">

    let table;
    var statusNames = ["", "未申报", "已申报", "等待受理", "已受理", "授权", "退回"];
    $(function () {
        table = js.table.init({
            url: ctx + "invention/query",
            showExport: false,
            column: [
                {
                    title: '序号', field: 'id', width: 50,
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {title: '发明专利名称', field: 'name', width: '150'},
                {title: '申请类型', field: 'typeName'},
                {title: '发明人', field: 'inventor', width: '200'},
                {title: '提报时间', field: 'applyTime'},
                {title: '受理时间', field: 'acceptanceTime'},
                {title: '授权时间', field: 'authorizdeTime'},
                {title: '专利编码', field: 'pantentCode'},
                {title: '公司专利奖励', field: 'reward'},
                {
                    title: '状态', field: 'status',
                    formatter: function (value) {
                        return statusNames[value];
                    }
                },
                {
                    title: '附件', field: 'certificateNo',
                    formatter: function (value) {
                        if (value) {
                            return '<a target="_blank" href="' + value + '">下载</a>'
                        }
                    }
                },
                {title: '涉及项目', field: 'projectRemark', width: '150'},
                {
                    title: '操作', width: '110',
                    formatter: function (value, row) {
                        let actions = [];
                        actions.push('<a class="btn btn-warning btn-xs" onclick="editIntention(' + js.jsonStringify(row) + ')">维护</a>');
                        actions.push('<a class="btn btn-danger btn-xs" onclick="del(' + row.id + ')">删除</a>');
                        actions.push('<a class="btn btn-info btn-xs" onclick="upload(' + row.id + ')">上传附件</a>');
                    }
                }
            ]
        })
    });

    //删除数据
    function del(id) {
        js.modal.confirm("确定要删除么？", function () {
            js.post({
                url: ctx + "invention/del",
                data: {id: id},
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        js.modal.success(result.msg);
                        js.table.refresh(table);
                    } else {
                        js.modal.warning(result.msg);
                    }
                }
            })
        })
    }

</script>
</body>
</html>
